package utils.com;

import java.util.ArrayList;
import java.util.List;

import model.com.SeasonInfo;
import android.content.Context;
import android.database.Cursor;
import database.com.DatabaseHelper;

public class DBtoSeasonListUtils {
	private Context context;
	private DatabaseHelper databaseHelper;
	private List<SeasonInfo> infos = null;
	
	public DBtoSeasonListUtils(List<SeasonInfo> infos, Context context) {
		super();
		this.context = context;
		this.infos = infos;
	}
	
	public List<SeasonInfo> getInfos() {
		return infos;
	}

	public void setInfos(List<SeasonInfo> infos) {
		this.infos = infos;
	}
	
	public List<SeasonInfo> getSeasonList(){
		List<SeasonInfo> infos = new ArrayList<SeasonInfo>();
		databaseHelper = new DatabaseHelper(context, "resource");
		Cursor cursor = databaseHelper.query("season", "*", null, null, null);
		cursor.moveToPosition(-1);
	    while(cursor.moveToNext()){
	    	SeasonInfo seasonInfo = new SeasonInfo();
	    	seasonInfo.setSeason_id(cursor.getInt(1));
	    	seasonInfo.setSeason_title(cursor.getString(2));
	    	seasonInfo.setSeason_count(cursor.getInt(3));
	    	seasonInfo.setSeason_info(cursor.getString(4));
	    	seasonInfo.setPic_url(cursor.getString(5));
	    	seasonInfo.setPic_name(cursor.getString(6));
	    	seasonInfo.setPic_size(cursor.getInt(7));
	    	seasonInfo.setImage_url(cursor.getString(8));
	    	seasonInfo.setImage_name(cursor.getString(9));
	    	seasonInfo.setImage_size(cursor.getInt(10));
	    	seasonInfo.setPic_localUrl(cursor.getString(11));
	    	seasonInfo.setImage_localUrl(cursor.getString(12));
	    	seasonInfo.setSeason_sort(cursor.getString(13));
			infos.add(seasonInfo);
	    }
      	cursor.close();
		return infos;
	}
}
